<template>
	<view class="">
		<u-cell-group>
			<u-cell icon="integral-fill" title="类型" value="出库支付"></u-cell>
			<u-cell icon="car-fill" title="车牌号" :value="car_number"></u-cell>
			<u-cell icon="rmb-circle-fill" title="支付金额" :value='money+"元" '></u-cell>
			<br/>
			<view class="div"></view>
			<view class="btn_box">
				<u-button type="primary" text="确定" @click='paymoney()'></u-button>
			</view>
		</u-cell-group>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				car_number: '0', //车牌号
				money: '0', //需要支付的金额
			};
		},
		onLoad(options) {
			this.car_number = options.car_number; //接受车牌号参数
		},
		mounted() {
			this.getmoney()
		},
		methods: {
			// 获取出库所需支付的金额
			async getmoney() {
				const {
					data: res
				} = await uni.$http.get('/car_info/pay/money', {
					'car_number': this.car_number,
				})
				if (res.code === 200) {
					this.money = res.money //赋予金额
				} else {
					// 弹出失败提示框
					uni.showToast({
						title: res.msg, // 提示的文字内容
						icon: 'error' // 提示图标
					});
				}
			},
			// 跳转支付界面
			paymoney() {
				uni.navigateTo({
					url: `/pages/pay/pay?car_number=${this.car_number}&type=user&money=${this.money}`,
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.box_btn{
		margin-top: 10px;
	}
	.div{
		height: 10px;
	}
</style>